//
//  UIColor+Extension.m
//  OC_Poj_demo
//
//  Created by weixin on 2018/7/17.
//  Copyright © 2018年 weixn. All rights reserved.
//

#import "UIColor+Extension.h"

@implementation UIColor (Extension)
+ (UIColor *)baseColor {
    return [UIColor colorWithHex:@"#D5BB8F"];
}
+ (UIColor *)baseColorEADDC7 {
    return [UIColor colorWithHex:@"#EADDC7"];
}
+ (UIColor *)backgroundColor {
    return [UIColor colorWithHex:@"#F0F0F6"];
}

+ (UIColor *)colorA1 {
    return [UIColor colorWithHex:@"#A1A1A1"];
}
+ (UIColor *)colorF7 {
    return [UIColor colorWithHex:@"#F7F7F7"];
}
+ (UIColor *)color22 {
    return [UIColor colorWithHex:@"#222222"];
}
+ (UIColor *)colorCC {
    return [UIColor colorWithHex:@"#CCCCCC"];
}
+ (UIColor *)colorED {
    return [UIColor colorWithHex:@"#EDEDED"];
}
+ (UIColor *)colorF75353 {
    return [UIColor colorWithHex:@"#F75353"];
}
+ (UIColor *)colorD9 {
    return [UIColor colorWithHex:@"#D9D9D9"];
}
+ (UIColor *)color66 {
    return [UIColor colorWithHex:@"#666666"];
}



+ (UIColor *)randomColor {
    return [UIColor whiteColor];
    //    return [UIColor colorWithRed:((arc4random() % 256) / 255.f) green:((arc4random() % 256) / 255.f) blue:((arc4random() % 256) / 255.f) alpha:1.0];


//#ifdef DEBUG
////    return [UIColor colorWithRed:((arc4random() % 256) / 255.f) green:((arc4random() % 256) / 255.f) blue:((arc4random() % 256) / 255.f) alpha:1.0];
//#else
//    return [UIColor whiteColor];
//#endif
    
    
}
+ (UIColor *)RGBColorWithR:(CGFloat)r g:(CGFloat)g b:(CGFloat)b {
    return [UIColor colorWithRed:r/255.f green:g/255.f blue:b/255.f alpha:1.f];
}
+ (UIColor *)colorWithHex:(NSString *)hexString {
    NSString *cString = [[hexString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];//字符串处理
    //例子，stringToConvert #ffffff
    if ([cString hasPrefix:@"#"])
        cString = [cString substringFromIndex:1];//去掉头
    if(cString.length != 6){
        return [UIColor blackColor];
    }
    //分别取RGB的值
    NSRange range;
    range.location = 0;
    range.length = 2;
    NSString *rString = [cString substringWithRange:range];
    
    range.location = 2;
    NSString *gString = [cString substringWithRange:range];
    
    range.location = 4;
    NSString *bString = [cString substringWithRange:range];
    
    unsigned int r, g, b;
    //NSScanner把扫描出的制定的字符串转换成Int类型
    [[NSScanner scannerWithString:rString] scanHexInt:&r];
    [[NSScanner scannerWithString:gString] scanHexInt:&g];
    [[NSScanner scannerWithString:bString] scanHexInt:&b];
    //转换为UIColor
    return [UIColor colorWithRed:((float)r / 255.0f)
                           green:((float)g / 255.0f)
                            blue:((float)b / 255.0f)
                           alpha:1.0f];
}
+ (UIColor *)defaultShadowColor {
    return [[UIColor grayColor] colorWithAlphaComponent:0.07];
}
+ (NSArray<UIColor *> *)defaultGradientBackgroundColors {
    return @[baseColorGradientL,
             baseColorGradientR];
}
+(void)setDefaulGradiennBackgroundColors:(UIView*)view{
     [view setGradientBackgroundWithColors:[self defaultGradientBackgroundColors] locations:nil startPoint:CGPointZero endPoint:CGPointMake(0, 1)];
}

@end
